<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<title>Exported from Notepad++</title>
<style type="text/css">
span {
	font-family: 'Courier New';
	font-size: 10pt;
	color: #000000;
}
.sc0 {
}
.sc1 {
	font-style: italic;
	color: #0000FF;
}
.sc2 {
	font-style: italic;
	color: #0000FF;
}
.sc4 {
	color: #8000FF;
}
.sc5 {
	font-weight: bold;
	font-style: italic;
	color: #0000FF;
}
.sc6 {
	font-weight: bold;
	color: #008000;
}
.sc7 {
	font-style: italic;
	text-decoration: underline;
	color: #FF0000;
}
.sc8 {
	font-weight: bold;
	font-style: italic;
	color: #008000;
}
.sc10 {
	font-weight: bold;
	color: #0080FF;
}
.sc11 {
}
.sc14 {
	color: #8080FF;
}
</style>
</head>
<body>
<div style="float: left; white-space: pre; line-height: 1; background: #FFFFFF; "><span class="sc2">// ================================================== //</span><span class="sc0">
</span><span class="sc2">// ============ TUTORIELS BEBOP 1.0 ================= //</span><span class="sc0">
</span><span class="sc2">// ================================================== //</span><span class="sc0">

</span><span class="sc2">// MontreBoard.bop</span><span class="sc0">
</span><span class="sc2">// Mathieu Barbin</span><span class="sc0">

</span><span class="sc1">/* 
    On reprend le code de la montre digitale,
    cette fois-ci l'heure est reglable dynamiquement
    par les boutons push de la bopboard.
*/</span><span class="sc0"> 

</span><span class="sc10">#</span><span class="sc5">include</span><span class="sc0"> </span><span class="sc10">&lt;</span><span class="sc11">stdlib</span><span class="sc10">.</span><span class="sc11">bop</span><span class="sc10">&gt;</span><span class="sc0">
</span><span class="sc10">#</span><span class="sc5">include</span><span class="sc0"> </span><span class="sc10">&lt;</span><span class="sc11">bopboard</span><span class="sc10">.</span><span class="sc11">bop</span><span class="sc10">&gt;</span><span class="sc0">

</span><span class="sc2">// Pour une plus grande fluidite de l'interface, </span><span class="sc0">
</span><span class="sc2">// l'horloge doit tourner un peu plus vite</span><span class="sc0">
</span><span class="sc10">#</span><span class="sc5">define</span><span class="sc0"> </span><span class="sc8">FREQ</span><span class="sc0"> </span><span class="sc4">256</span><span class="sc0">

</span><span class="sc10">#</span><span class="sc5">define</span><span class="sc0"> </span><span class="sc8">CADRAN_BOPBOARD</span><span class="sc0"> </span><span class="sc4">0</span><span class="sc0"> </span><span class="sc2">// Si un cadran digital est implemente sur la bopboard</span><span class="sc0">

</span><span class="sc5">ROM</span><span class="sc0"> </span><span class="sc8">Dec7</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc4">4</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc4">7</span><span class="sc10">)</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc5">text</span><span class="sc0"> </span><span class="sc10">{</span><span class="sc0">
      </span><span class="sc11">zero</span><span class="sc0">    </span><span class="sc11">un</span><span class="sc0">     </span><span class="sc11">deux</span><span class="sc0">    </span><span class="sc11">trois</span><span class="sc0">  </span><span class="sc11">quatre</span><span class="sc0">
        </span><span class="sc4">1011111</span><span class="sc0"> </span><span class="sc4">0000110</span><span class="sc0"> </span><span class="sc4">0111011</span><span class="sc0"> </span><span class="sc4">0101111</span><span class="sc0"> </span><span class="sc4">1100110</span><span class="sc0">
     </span><span class="sc11">cinq</span><span class="sc0">     </span><span class="sc11">six</span><span class="sc0">    </span><span class="sc11">sept</span><span class="sc0">     </span><span class="sc11">huit</span><span class="sc0">   </span><span class="sc11">neuf</span><span class="sc0">
        </span><span class="sc4">1101101</span><span class="sc0"> </span><span class="sc4">1111101</span><span class="sc0"> </span><span class="sc4">0000111</span><span class="sc0"> </span><span class="sc4">1111111</span><span class="sc0"> </span><span class="sc4">1101111</span><span class="sc0">  
</span><span class="sc10">}</span><span class="sc0">

</span><span class="sc5">ROM</span><span class="sc0"> </span><span class="sc8">C24</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc4">5</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc4">8</span><span class="sc10">)</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc5">text</span><span class="sc0"> </span><span class="sc10">{</span><span class="sc0">
    </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">0000</span><span class="sc0">  </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">0001</span><span class="sc0">  </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">0010</span><span class="sc0">  </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">0011</span><span class="sc0">  </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">0100</span><span class="sc0"> 
    </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">0101</span><span class="sc0">  </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">0110</span><span class="sc0">  </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">0111</span><span class="sc0">  </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">1000</span><span class="sc0">  </span><span class="sc4">0000</span><span class="sc10">|</span><span class="sc4">1001</span><span class="sc0">

    </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">0000</span><span class="sc0">  </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">0001</span><span class="sc0">  </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">0010</span><span class="sc0">  </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">0011</span><span class="sc0">  </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">0100</span><span class="sc0"> 
    </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">0101</span><span class="sc0">  </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">0110</span><span class="sc0">  </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">0111</span><span class="sc0">  </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">1000</span><span class="sc0">  </span><span class="sc4">0001</span><span class="sc10">|</span><span class="sc4">1001</span><span class="sc0">

    </span><span class="sc4">0010</span><span class="sc10">|</span><span class="sc4">0000</span><span class="sc0">  </span><span class="sc4">0010</span><span class="sc10">|</span><span class="sc4">0001</span><span class="sc0">  </span><span class="sc4">0010</span><span class="sc10">|</span><span class="sc4">0010</span><span class="sc0">  </span><span class="sc4">0010</span><span class="sc10">|</span><span class="sc4">0011</span><span class="sc0">  </span><span class="sc4">0010</span><span class="sc10">|</span><span class="sc4">0100</span><span class="sc0"> 
</span><span class="sc10">}</span><span class="sc0">

</span><span class="sc8">Adder</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">i</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">rst</span><span class="sc10">)</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">s</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">r</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc11">s</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">Z</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc0"> </span><span class="sc6">mux</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">rst</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc6">gnd</span><span class="sc10">(),</span><span class="sc0"> </span><span class="sc6">xor</span><span class="sc10">(</span><span class="sc11">s</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">)</span><span class="sc0"> </span><span class="sc10">)</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc11">r</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">and</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">s</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">);</span><span class="sc0">
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc8">CM10</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">i</span><span class="sc10">)</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">s</span><span class="sc0"> </span><span class="sc10">:</span><span class="sc0"> </span><span class="sc10">[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">rst</span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">with</span><span class="sc0"> </span><span class="sc5">unused</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc2">//rst = 1 si s[0..3] = 9 et i = 1</span><span class="sc0">
    </span><span class="sc11">rst</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">and</span><span class="sc10">[</span><span class="sc4">5</span><span class="sc10">](</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">3</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc6">not</span><span class="sc10">(</span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">2</span><span class="sc10">]),</span><span class="sc0"> </span><span class="sc6">not</span><span class="sc10">(</span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">1</span><span class="sc10">]),</span><span class="sc0"> </span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]);</span><span class="sc0">

    </span><span class="sc5">for</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc4">0</span><span class="sc0"> </span><span class="sc5">to</span><span class="sc0"> </span><span class="sc4">3</span><span class="sc0"> 
        </span><span class="sc11">s</span><span class="sc10">[</span><span class="sc11">i</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">4</span><span class="sc0"> </span><span class="sc10">-</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Adder</span><span class="sc10">(</span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">3</span><span class="sc0"> </span><span class="sc10">-</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">rst</span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">for</span><span class="sc10">;</span><span class="sc0">

    </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">id</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">i</span><span class="sc10">);</span><span class="sc0">
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc8">CM6</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">i</span><span class="sc10">)</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">..</span><span class="sc4">3</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">rst</span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">with</span><span class="sc0"> </span><span class="sc5">unused</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">3</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">gnd</span><span class="sc10">();</span><span class="sc0">

    </span><span class="sc2">// rest = 1 &lt;=&gt; s = 5 et i = 1 </span><span class="sc0">
    </span><span class="sc11">rst</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">and</span><span class="sc10">[</span><span class="sc4">4</span><span class="sc10">](</span><span class="sc11">i</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">1</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc6">not</span><span class="sc10">(</span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">2</span><span class="sc10">])</span><span class="sc0"> </span><span class="sc10">,</span><span class="sc11">s</span><span class="sc10">[</span><span class="sc4">3</span><span class="sc10">]);</span><span class="sc0">

    </span><span class="sc5">for</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc4">1</span><span class="sc0"> </span><span class="sc5">to</span><span class="sc0"> </span><span class="sc4">3</span><span class="sc0"> 
        </span><span class="sc11">s</span><span class="sc10">[</span><span class="sc11">i</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">4</span><span class="sc0"> </span><span class="sc10">-</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Adder</span><span class="sc10">(</span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">3</span><span class="sc0"> </span><span class="sc10">-</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">rst</span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">for</span><span class="sc10">;</span><span class="sc0">

    </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">id</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">i</span><span class="sc10">);</span><span class="sc0">  
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc8">CM60</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">su</span><span class="sc0"> </span><span class="sc10">:</span><span class="sc0"> </span><span class="sc10">[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">sd</span><span class="sc0"> </span><span class="sc10">:</span><span class="sc0"> </span><span class="sc10">[</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">o</span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc11">su</span><span class="sc10">:[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc11">ou</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">CM10</span><span class="sc10">(</span><span class="sc11">i</span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc11">sd</span><span class="sc10">:[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc11">o</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">CM6</span><span class="sc10">(</span><span class="sc11">ou</span><span class="sc10">);</span><span class="sc0">
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc2">// unused : les variables inutiles (evite le warning)</span><span class="sc0">

</span><span class="sc8">C24</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">t</span><span class="sc10">:[</span><span class="sc4">5</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">o</span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">with</span><span class="sc0"> </span><span class="sc5">unused</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">5</span><span class="sc10">]</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc11">o</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">and</span><span class="sc10">[</span><span class="sc4">6</span><span class="sc10">](</span><span class="sc11">t</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">t</span><span class="sc10">[</span><span class="sc4">2</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">t</span><span class="sc10">[</span><span class="sc4">3</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">t</span><span class="sc10">[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc6">not</span><span class="sc10">(</span><span class="sc11">t</span><span class="sc10">[</span><span class="sc4">1</span><span class="sc10">]),</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">);</span><span class="sc0">

    </span><span class="sc5">for</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc4">0</span><span class="sc0"> </span><span class="sc5">to</span><span class="sc0"> </span><span class="sc4">4</span><span class="sc0"> 
        </span><span class="sc11">t</span><span class="sc10">[</span><span class="sc11">i</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">5</span><span class="sc0"> </span><span class="sc10">-</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Adder</span><span class="sc10">(</span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">4</span><span class="sc0"> </span><span class="sc10">-</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">o</span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">for</span><span class="sc10">;</span><span class="sc0">

    </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">id</span><span class="sc10">(</span><span class="sc11">i</span><span class="sc10">);</span><span class="sc0">
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">


</span><span class="sc2">// Diviseur d'horloge selon des puissances de 2</span><span class="sc0">

</span><span class="sc8">CM2</span><span class="sc10">[</span><span class="sc8">P</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">sec</span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">with</span><span class="sc0"> </span><span class="sc5">unused</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">a</span><span class="sc10">[</span><span class="sc4">1</span><span class="sc10">..</span><span class="sc8">P</span><span class="sc10">]</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
        </span><span class="sc11">g</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">gnd</span><span class="sc10">();</span><span class="sc0">
        </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">id</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">i</span><span class="sc10">);</span><span class="sc0">
        </span><span class="sc11">sec</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">id</span><span class="sc10">(</span><span class="sc11">c</span><span class="sc10">[</span><span class="sc8">P</span><span class="sc10">]);</span><span class="sc0">

        </span><span class="sc5">for</span><span class="sc0"> </span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc4">1</span><span class="sc0"> </span><span class="sc5">to</span><span class="sc0"> </span><span class="sc8">P</span><span class="sc0">
          </span><span class="sc11">a</span><span class="sc10">[</span><span class="sc11">i</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">c</span><span class="sc10">[</span><span class="sc11">i</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Adder</span><span class="sc10">(</span><span class="sc11">c</span><span class="sc10">[</span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">-</span><span class="sc0"> </span><span class="sc4">1</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">g</span><span class="sc10">);</span><span class="sc0"> 
        </span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">for</span><span class="sc10">;</span><span class="sc0">
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc2">// On modifie l'interface de la montre : ce coup-ci, on donne des bits</span><span class="sc0">
</span><span class="sc2">// d'entree pour incrementer les heures, les minutes, ou les secondes</span><span class="sc0">
</span><span class="sc8">Montre</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc11">incrS</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">incrM</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">incrH</span><span class="sc10">)</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">s1</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">s10</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">m1</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">m10</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">h1</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">h10</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">)</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">   
    </span><span class="sc11">s1</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">rom_Dec7</span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">su</span><span class="sc10">:[-</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc11">s10</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">rom_Dec7</span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">sd</span><span class="sc10">:[-</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc11">m1</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">rom_Dec7</span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">mu</span><span class="sc10">:[-</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc11">m10</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">rom_Dec7</span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">md</span><span class="sc10">:[-</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">

    </span><span class="sc11">h1</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">rom_Dec7</span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">hu</span><span class="sc10">:[-</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc11">h10</span><span class="sc10">:[</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">rom_Dec7</span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">hd</span><span class="sc10">:[-</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">

    </span><span class="sc2">// la simulation est reglee sur FREQ cycles par seconde</span><span class="sc0">

    </span><span class="sc11">i</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">clock</span><span class="sc10">();</span><span class="sc0">
    </span><span class="sc11">sec</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">CM2</span><span class="sc10">[</span><span class="sc6">log</span><span class="sc0"> </span><span class="sc8">FREQ</span><span class="sc10">](</span><span class="sc11">i</span><span class="sc10">);</span><span class="sc0">
</span><span class="sc2">//  $bopwatch.display("su:[4], sd:[4] = %4b, %4b", su:[4], sd:[4]);</span><span class="sc0">

    </span><span class="sc11">su</span><span class="sc10">:[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc11">sd</span><span class="sc10">:[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc11">mn</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">CM60</span><span class="sc10">(</span><span class="sc6">or</span><span class="sc10">(</span><span class="sc11">incrS</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">sec</span><span class="sc10">));</span><span class="sc0">
    </span><span class="sc11">mu</span><span class="sc10">:[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc11">md</span><span class="sc10">:[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc11">hr</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">CM60</span><span class="sc10">(</span><span class="sc6">or</span><span class="sc10">(</span><span class="sc11">incrM</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">mn</span><span class="sc10">));</span><span class="sc0">

    </span><span class="sc11">t</span><span class="sc10">:[</span><span class="sc4">5</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">_</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">C24</span><span class="sc10">(</span><span class="sc6">or</span><span class="sc10">(</span><span class="sc11">incrH</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">hr</span><span class="sc10">));</span><span class="sc0">

    </span><span class="sc11">hd</span><span class="sc10">:[</span><span class="sc4">4</span><span class="sc10">],</span><span class="sc0"> </span><span class="sc11">hu</span><span class="sc10">:[</span><span class="sc4">4</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">rom_C24</span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">t</span><span class="sc10">:[-</span><span class="sc4">5</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">

</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc2">// MontreReglable : on utilise les 3 premiers push de la bopboard</span><span class="sc0">
</span><span class="sc2">// Comme indicateur d'incrementation pour reglage</span><span class="sc0">
</span><span class="sc8">MontreReglable</span><span class="sc0"> </span><span class="sc10">()</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">s</span><span class="sc10">:[</span><span class="sc4">42</span><span class="sc10">]</span><span class="sc0">
</span><span class="sc5">with</span><span class="sc0"> </span><span class="sc5">unused</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc11">push</span><span class="sc10">[</span><span class="sc4">3</span><span class="sc10">..</span><span class="sc4">7</span><span class="sc10">]</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc11">s</span><span class="sc10">:[</span><span class="sc4">42</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Montre</span><span class="sc10">(</span><span class="sc0"> </span><span class="sc11">incrS</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">incrM</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">incrH</span><span class="sc0"> </span><span class="sc10">);</span><span class="sc0">
    </span><span class="sc2">// Acces au bus push</span><span class="sc0">
    </span><span class="sc11">push</span><span class="sc10">:[</span><span class="sc4">8</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">$</span><span class="sc11">bopboard</span><span class="sc10">.</span><span class="sc11">push</span><span class="sc10">();</span><span class="sc0">
    </span><span class="sc2">// filtre posedge pour regler eviter une incrementation chaque cycle</span><span class="sc0">
    </span><span class="sc11">incrS</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Posedge</span><span class="sc10">(</span><span class="sc11">push</span><span class="sc10">[</span><span class="sc4">0</span><span class="sc10">]);</span><span class="sc0">
    </span><span class="sc11">incrM</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Posedge</span><span class="sc10">(</span><span class="sc11">push</span><span class="sc10">[</span><span class="sc4">1</span><span class="sc10">]);</span><span class="sc0">
    </span><span class="sc11">incrH</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">Posedge</span><span class="sc10">(</span><span class="sc11">push</span><span class="sc10">[</span><span class="sc4">2</span><span class="sc10">]);</span><span class="sc0">
</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc2">// La simulation finale</span><span class="sc0">
</span><span class="sc10">[</span><span class="sc7">Main</span><span class="sc10">]</span><span class="sc0">
</span><span class="sc8">Simulation</span><span class="sc0"> </span><span class="sc10">()</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc10">()</span><span class="sc0">
</span><span class="sc5">where</span><span class="sc0">
    </span><span class="sc2">// Regulateur de frequence</span><span class="sc0">
    </span><span class="sc11">_</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">pipe</span><span class="sc10">(</span><span class="sc14">"freq.bpix -f $(FREQ)"</span><span class="sc10">);</span><span class="sc0">

    </span><span class="sc2">// La montre reglable</span><span class="sc0">
    </span><span class="sc11">s</span><span class="sc10">:[</span><span class="sc4">42</span><span class="sc10">]</span><span class="sc0"> </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc8">MontreReglable</span><span class="sc10">();</span><span class="sc0">

    </span><span class="sc2">// Envoi des bits du cadran, soit a l'application cadran</span><span class="sc0">
    </span><span class="sc2">// soit sur le cadran de la bopboard si il y en a un</span><span class="sc0">
        
    </span><span class="sc5">if</span><span class="sc0"> </span><span class="sc8">CADRAN_BOPBOARD</span><span class="sc0">
    </span><span class="sc5">then</span><span class="sc0">
        </span><span class="sc10">$</span><span class="sc11">bopboard</span><span class="sc10">.</span><span class="sc11">cadran</span><span class="sc10">(</span><span class="sc11">s</span><span class="sc10">:[</span><span class="sc4">42</span><span class="sc10">]);</span><span class="sc0">
    </span><span class="sc5">else</span><span class="sc0">
        </span><span class="sc10">=</span><span class="sc0"> </span><span class="sc6">pipe</span><span class="sc10">(</span><span class="sc14">"cadran"</span><span class="sc10">,</span><span class="sc0"> </span><span class="sc11">s</span><span class="sc10">:[</span><span class="sc4">42</span><span class="sc10">]);</span><span class="sc0">
    </span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">if</span><span class="sc10">;</span><span class="sc0">

</span><span class="sc5">end</span><span class="sc0"> </span><span class="sc5">where</span><span class="sc10">;</span><span class="sc0">
</span></div></body>
</html>
